package com.example.rabbit.consumer;

import com.example.rabbit.config.DelayedQueueConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;

import java.nio.charset.StandardCharsets;
import java.util.Date;

/**
 * @Author ifredomvip@gmail.com
 * @Date 2022/8/11 16:51
 * @Version 1.0.0
 * @Description
 **/
@Slf4j
//@Component
public class DelayedQueueConsumer1 {


    @RabbitListener(queues = DelayedQueueConfig.DELAYED_QUEUE_NAME)
    public void consumerDelayedMessage(Message message) {
        String msg = new String(message.getBody(), StandardCharsets.UTF_8);

        log.info("监听延迟队列" + (new Date()).toString() + "收到延迟消息:" + msg);

    }
}
